<template>
  <div class="header">
    <div class="nav-method">
      <li :class="active ==='portrait'?'activeClass':''" @click="setType('portrait')">XAPI</li>
      <li :class="active ==='sample'?'activeClass':''" @click="setType('sample')">数据采样</li>
    </div>
    <div class="nav-admin">
      <i
        class="iconfont icon-yonghuming"
        style="color:#fff;font-size:30px;"
      ></i>
      <span style="color:#fff;font-size:12px">欢迎您, {{userForm.name}}</span>
      <span style="height:30px;border-right:1px solid #fff;margin:0 15px"></span>
      <i
        class="iconfont icon-tuichu"
        style="color:#fff;font-size:25px;cursor:pointer"
        @click="logOut"
      ></i>
    </div>
  </div>
</template>

<script>
  export default {
    data() {
      return {
        active:'portrait',
        userForm: {
          name: ""
        }
      }
    },
    methods: {
      logOut() {
        this.$router.push({
          path: '/login'
        })
        // this.$http.get('/auths/logout/').then(
        //   response => {
        //     this.$store.commit('outUser')
        //     this.$message.success('登出成功')
        //     this.$router.push({
        //       path: '/login'
        //     })
        //   }
        // )
      },
      setType(type) {
        this.$router.push({
          path: this.$route.path,
          query: {
            type: type
          }
        })
        this.active = type
        this.$store.commit('setType', type)
      }
    },
    created() {
      console.log(this.$route.path)
      this.userForm.name = this.$store.getters.getUser
    }
  }

</script>

<style
  lang="scss"
  scoped
>
  .header {
    .nav-method {
      position: absolute;
      left: 300px;
      line-height: 60px;
      color: #fff;
      .activeClass{
        text-decoration: underline
      }
      li {
        list-style-type: none;
        padding: 0 20px;
        float: left;
        cursor: pointer;

        &:hover {
          text-decoration: underline
        }
      }
    }

    .nav-admin {
      height: 60px;
      text-align: right;

      span {
        line-height: 60px;
      }

      i {
        position: relative;
        padding-right: 5px;

        &:nth-child(1) {
          top: 5px;
        }

        &:last-child {
          top: 3px;
        }

      }
    }
  }

</style>
